let pageNav = [
  '../scanCode/scanCode',
  '',
  '../historyList/historyList',
  '../tab2/tab2',
  '../tab3/tab3',
  '../removeBind/removeBind'
]



Page({
  data: {
    cardCur: 0,
    swiperList: [{
      id: 0,
      type: 'image',
      url: 'https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fn.sinaimg.cn%2Fgx%2Fcrawl%2F62%2Fw550h312%2F20180325%2F2SaH-fysnevm8290209.jpg&refer=http%3A%2F%2Fn.sinaimg.cn&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=jpeg?sec=1623059155&t=2b1fafb582bc92b8e4f987542ab0800a'
    }, {
      id: 1,
      type: 'image',
      url: 'https://ss3.bdstatic.com/70cFv8Sh_Q1YnxGkpoWK1HF6hhy/it/u=2223945740,1099997311&fm=26&gp=0.jpg',
    }, {
      id: 2,
      type: 'image',
      url: 'https://ss0.bdstatic.com/70cFuHSh_Q1YnxGkpoWK1HF6hhy/it/u=2961336989,2861936643&fm=26&gp=0.jpg'
    }, {
      id: 3,
      type: 'image',
      url: 'https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fwww.eol.cn%2Fhtml%2Fuc%2Fyz%2Fs%2Fhainu%2Fimages%2Fpic1.jpg&refer=http%3A%2F%2Fwww.eol.cn&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=jpeg?sec=1623059269&t=be9c1d122bd1ddc42aa24ab9c44bf9f0'
    }, {
      id: 4,
      type: 'image',
      url: 'https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fwww.yanbm.com%2Fd%2Fcj%2Fhndx3%2Fimage%2F59f2cd2ba94d5.jpg&refer=http%3A%2F%2Fwww.yanbm.com&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=jpeg?sec=1623059289&t=08dae1fd014438f1ac64295ab74a0b5d'
    }, {
      id: 5,
      type: 'image',
      url: 'https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fimg.mp.itc.cn%2Fupload%2F20161220%2F59cab9c2dc0c45b0801aa3cd1f51a4e5_th.jpeg&refer=http%3A%2F%2Fimg.mp.itc.cn&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=jpeg?sec=1623059318&t=db5efa26ef1411a84c297a521fd7086d'
    }, {
      id: 6,
      type: 'image',
      url: 'https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fdingyue.ws.126.net%2F02LJNzC9PqEckI7t3tnpBGK0Wxs3rPyfUGnX1qnZ3V8vQ1571687060858compressflag.jpg&refer=http%3A%2F%2Fdingyue.ws.126.net&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=jpeg?sec=1623059352&t=16ff7838c7554d4476362ec8c738af52'
    }],
    list: [{
        icon: 'evaluate_fill',
        color: 'red',
        text: "立即签到"
      },
      {
        icon: 'markfill',
        color: 'olive',
        text: "我的评论"
      },
      {
        icon: 'taoxiaopu',
        color: 'mauve',
        text: "签到记录"
      },
      {
        icon: 'formfill',
        color: 'brown',
        text: "我的课表"
      },
      {
        icon: 'group_fill',
        color: 'green',
        text: "个人信息"
      },
      {
        icon: 'fork',
        color: 'orange',
        text: "解除绑定"
      },
    ],

  },
  // 导航栏跳转
  goPage(e) {
    console.log(e.currentTarget.dataset.index)
    let index = e.currentTarget.dataset.index
    let toPage = pageNav[index]
    wx.navigateTo({
      url: toPage, //跳转到指定页面
    })
    console.log(typeof(toPage))

  },




  onLoad() {
    this.towerSwiper('swiperList');
    // 初始化towerSwiper 传已有的数组名即可
  },
  DotStyle(e) {
    this.setData({
      DotStyle: e.detail.value
    })
  },
  // cardSwiper
  cardSwiper(e) {
    this.setData({
      cardCur: e.detail.current
    })
  },
  // towerSwiper
  // 初始化towerSwiper
  towerSwiper(name) {
    let list = this.data[name];
    for (let i = 0; i < list.length; i++) {
      list[i].zIndex = parseInt(list.length / 2) + 1 - Math.abs(i - parseInt(list.length / 2))
      list[i].mLeft = i - parseInt(list.length / 2)
    }
    this.setData({
      swiperList: list
    })
  },
  // towerSwiper触摸开始
  towerStart(e) {
    this.setData({
      towerStart: e.touches[0].pageX
    })
  },
  // towerSwiper计算方向
  towerMove(e) {
    this.setData({
      direction: e.touches[0].pageX - this.data.towerStart > 0 ? 'right' : 'left'
    })
  },
  // towerSwiper计算滚动
  towerEnd(e) {
    let direction = this.data.direction;
    let list = this.data.swiperList;
    if (direction == 'right') {
      let mLeft = list[0].mLeft;
      let zIndex = list[0].zIndex;
      for (let i = 1; i < list.length; i++) {
        list[i - 1].mLeft = list[i].mLeft
        list[i - 1].zIndex = list[i].zIndex
      }
      list[list.length - 1].mLeft = mLeft;
      list[list.length - 1].zIndex = zIndex;
      this.setData({
        swiperList: list
      })
    } else {
      let mLeft = list[list.length - 1].mLeft;
      let zIndex = list[list.length - 1].zIndex;
      for (let i = list.length - 1; i > 0; i--) {
        list[i].mLeft = list[i - 1].mLeft
        list[i].zIndex = list[i - 1].zIndex
      }
      list[0].mLeft = mLeft;
      list[0].zIndex = zIndex;
      this.setData({
        swiperList: list
      })
    }
  }
})